"""
卡牌基础类：定义卡牌数据结构与基本操作
"""

class Card:
    RANKS = ['3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2']
    VALUES = {r: i for i, r in enumerate(RANKS)}
    SPECIALS = {'BJ': 14, 'RJ': 15}

    def __init__(self, identifier):
        # 处理特殊牌
        if identifier in self.SPECIALS:
            self.rank = identifier
            self.suit = None
            self.value = self.SPECIALS[identifier]  # 直接使用特殊牌值
        else:
            # 处理普通牌
            self.rank, self.suit = identifier.split('-')
            self.value = self.VALUES[self.rank]  # 普通牌从VALUES获取值

    def __lt__(self, other):
        return self.value < other.value

    def __repr__(self):
        return f"Card('{self.rank}{'-'+self.suit if self.suit else ''}')"